package com.chat.api.controller;

import com.chat.api.request.ChatRequest;
import com.chat.api.response.ChatResponse;
import com.chat.api.service.chatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private chatService chatService;

    /**
     * 聊天接口
     *
     * @param chatRequest
     */
    @CrossOrigin
    @PostMapping("/reqMsg")
    @ResponseBody
    public ChatResponse sseChat(@RequestBody ChatRequest chatRequest, HttpServletResponse response) {
        String answer = chatService.chatMsg(chatRequest);
        return new ChatResponse(answer);
    }
}
